import React, {Component} from 'react';
import {
    Button,
    View,
    TouchableOpacity,
    Text,
    StyleSheet,
    Image
} from 'react-native';
import GlobalStyles from '../../res/styles/GlobalStyles';
export default class LoginScreen extends Component {
    componentWillMount() {
        storage
            .load({key: 'token'})
            .then(ret => {
                console.log(ret);
                if (ret != null) {
                    this
                        .props
                        .navigation
                        .navigate('MainTab');
                    
                }
            })
            .catch(err => {
                console.warn(err.message);
            });
    }
    render() {
        const {navigate} = this.props.navigation;
        return (
            <View style={{width:'100%' ,height:'100%'}} >
                <View
                    style={{
                    width: '100%',
                    height: '80%',
                    marginTop: 48
                }}
                    alignItems='center'>
                    <Image source={require('../../res/img/ic_mobile.png')}/>
                    <Text style={{
                        marginTop: 20
                    }}>彼岸是金山，我们是摆渡人</Text>
                </View>
        
                    <View flexDirection='row' justifyContent='space-around' >
                        <TouchableOpacity style={styles.wechatLoginButton}>
                            <Text
                                style={{
                                color: 'white'
                            }}>微信登录</Text>
                        </TouchableOpacity>
                        <TouchableOpacity
                            style={styles.phoneLoginButton}
                            onPress={() => navigate('PhoneLogin')}
                            alignSelf='flex-end'>
                            <Text
                                style={{
                                color: GlobalStyles.primaryColor
                            }}>手机登录</Text>
                        </TouchableOpacity>
                </View>
            </View>
        );
    }
}
const styles = StyleSheet.create({
    wechatLoginButton: {
        padding: 16,
        paddingLeft: 48,
        paddingRight: 48,
        backgroundColor: GlobalStyles.primaryColor,
        borderColor: GlobalStyles.primaryColor,
        borderWidth: 1,
        borderRadius: 5

    },
    phoneLoginButton: {
        padding: 16,
        paddingLeft: 48,
        paddingRight: 48,
        borderColor: GlobalStyles.primaryColor,
        borderWidth: 1,
        borderRadius: 5
    }
});